package com.lykj.lib_base.internal.utils

import android.content.Context
import android.graphics.Typeface

/**
 * ================================================
 * 全局字体工具类
 * ================================================
 *
 * @author gosha
 * @date 2022/10/8-14:52
 */
object FontUtils {
    private var regularFontType: Typeface? = null
    private var lightFontType: Typeface? = null
    private var mediumFontType: Typeface? = null
    private var heavyFontType: Typeface? = null
    private var extraLightFontType: Typeface? = null

    //常规-字重
    open fun getRegularTypeFace(context: Context): Typeface? {
        if (regularFontType == null)
            regularFontType = Typeface.createFromAsset(context.assets, "fonts/PINGFANG REGULAR.TTF")

        return regularFontType
    }

    //轻-字重
    open fun getLightTypeFace(context: Context): Typeface? {
        if (lightFontType == null)
            lightFontType = Typeface.createFromAsset(context.assets, "fonts/PINGFANG LIGHT.TTF")

        return lightFontType
    }

    //中等-字重
    open fun getMediumTypeFace(context: Context): Typeface? {
        if (mediumFontType == null)
            mediumFontType = Typeface.createFromAsset(context.assets, "fonts/PINGFANG MEDIUM.TTF")

        return mediumFontType
    }

    //重-字重
    open fun getHeavyTypeFace(context: Context): Typeface? {
        if (heavyFontType == null)
            heavyFontType = Typeface.createFromAsset(context.assets, "fonts/PINGFANG HEAVY.TTF")

        return heavyFontType
    }

    //额外轻-字重
    open fun getExtraLightTypeFace(context: Context): Typeface? {
        if (extraLightFontType == null)
            extraLightFontType =
                Typeface.createFromAsset(context.assets, "fonts/PINGFANG EXTRALIGHT.TTF")

        return extraLightFontType
    }
}